define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'storegroup/index' + location.search,
                    add_url: 'storegroup/add',
                    edit_url: 'storegroup/edit',
                    del_url: 'storegroup/del',
                    multi_url: 'storegroup/multi',
                    import_url: 'storegroup/import',
                    table: 'store_group',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider_id', title: __('Rider_id')},
                        {field: 'createtime', title: __('Createtime'), operate: 'RANGE',addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'user.id', title: __('User.id')},
                        {field: 'user.group_id', title: __('User.group_id')},
                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
                        {field: 'user.password', title: __('User.password'), operate: 'LIKE'},
                        {field: 'user.salt', title: __('User.salt'), operate: 'LIKE'},
                        {field: 'user.email', title: __('User.email'), operate: 'LIKE'},
                        {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
                        {field: 'user.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'user.level', title: __('User.level')},
                        {field: 'user.gender', title: __('User.gender')},
                        {field: 'user.birthday', title: __('User.birthday'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'user.bio', title: __('User.bio'), operate: 'LIKE'},
                        {field: 'user.money', title: __('User.money'), operate:'BETWEEN'},
                        {field: 'user.score', title: __('User.score')},
                        {field: 'user.successions', title: __('User.successions')},
                        {field: 'user.maxsuccessions', title: __('User.maxsuccessions')},
                        {field: 'user.prevtime', title: __('User.prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'user.logintime', title: __('User.logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'user.loginip', title: __('User.loginip'), operate: 'LIKE'},
                        {field: 'user.loginfailure', title: __('User.loginfailure')},
                        {field: 'user.loginfailuretime', title: __('User.loginfailuretime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'user.joinip', title: __('User.joinip'), operate: 'LIKE'},
                        {field: 'user.jointime', title: __('User.jointime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'user.createtime', title: __('User.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'user.updatetime', title: __('User.updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'user.token', title: __('User.token'), operate: 'LIKE'},
                        {field: 'user.status', title: __('User.status'), operate: 'LIKE', formatter: Table.api.formatter.status},
                        {field: 'user.verification', title: __('User.verification'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.store_name', title: __('User.store_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.store_image', title: __('User.store_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'user.address', title: __('User.address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.business_txt', title: __('User.business_txt'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.contact_name', title: __('User.contact_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.contact_tel', title: __('User.contact_tel'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.authen', title: __('User.authen')},
                        {field: 'user.remark', title: __('User.remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.authen_type', title: __('User.authen_type')},
                        {field: 'user.is_collect', title: __('User.is_collect')},
                        {field: 'user.discount', title: __('User.discount'), operate:'BETWEEN'},
                        {field: 'rider.id', title: __('Rider.id')},
                        {field: 'rider.nickname', title: __('Rider.nickname'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.avatar', title: __('Rider.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'rider.name', title: __('Rider.name'), operate: 'LIKE'},
                        {field: 'rider.mobile', title: __('Rider.mobile'), operate: 'LIKE'},
                        {field: 'rider.password', title: __('Rider.password'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.switch', title: __('Rider.switch'), table: table, formatter: Table.api.formatter.toggle},
                        {field: 'rider.tips', title: __('Rider.tips'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.authen', title: __('Rider.authen')},
                        {field: 'rider.remark', title: __('Rider.remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.createtime', title: __('Rider.createtime'), operate: 'LIKE'},
                        {field: 'rider.province_name', title: __('Rider.province_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.city_name', title: __('Rider.city_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.district_name', title: __('Rider.district_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.address', title: __('Rider.address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.province_id', title: __('Rider.province_id')},
                        {field: 'rider.city_id', title: __('Rider.city_id')},
                        {field: 'rider.district_id', title: __('Rider.district_id')},
                        {field: 'rider.contact_name', title: __('Rider.contact_name'), operate: 'LIKE'},
                        {field: 'rider.contact_tel', title: __('Rider.contact_tel'), operate: 'LIKE'},
                        {field: 'rider.legalLicenceFrontUrl', title: __('Rider.legalLicenceFrontUrl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        {field: 'rider.legalLicenceBackUrl', title: __('Rider.legalLicenceBackUrl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        {field: 'rider.bankCode', title: __('Rider.bankCode'), operate: 'LIKE'},
                        {field: 'rider.bankCardNo', title: __('Rider.bankCardNo'), operate: 'LIKE'},
                        {field: 'rider.applicationStatus', title: __('Rider.applicationStatus'), operate: 'LIKE', formatter: Table.api.formatter.status},
                        {field: 'rider.merchantNo', title: __('Rider.merchantNo'), operate: 'LIKE'},
                        {field: 'rider.requestNo', title: __('Rider.requestNo'), operate: 'LIKE'},
                        {field: 'rider.progressDescription', title: __('Rider.progressDescription'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.intentionAuthUrl', title: __('Rider.intentionAuthUrl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        {field: 'rider.intentionAuthUrl_code', title: __('Rider.intentionAuthUrl_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.agreementSignUrl', title: __('Rider.agreementSignUrl'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        {field: 'rider.agreementSignUrl_code', title: __('Rider.agreementSignUrl_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider.auditOpinion', title: __('Rider.auditOpinion'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
